let lng;
let lat;
Page({
    data: {
        longitude: 120.63212,
        latitude: 31.262,
        scale: 13
    },
    /**
     * 生命周期：页面初始化加载
     */
    onLoad: function () {
        console.log("onLoad");
        let that = this;
        wx.getLocation({
            altitude: true,
            success: function (res) {
                console.log(res);
                lng = res.longitude;
                lat = res.latitude;
                that.setData({
                    longitude: res.longitude,
                    latitude: res.latitude,
                    markers: [{
                        longitude: res.longitude,
                        latitude: res.latitude,
                        iconPath: "/resources/pin.png"
                    }],
                    controls: [{
                        id: 1,
                        position: {
                            left: 10,
                            // top: res.windowHeight - 200,
                            top: 100,
                            width: 30,
                            height: 30
                        },
                        iconPath: '/resources/location.png',
                        clickable: true
                    }]
                });
                console.log(that.data.longitude);
                console.log(that.data.latitude);
            }
        })
    },
    /**
     * 事件函数
     */
    controlTap: function (e) {
        console.log(e);
        switch (e.controlId) {
            case 1:
                this.setData({
                    longitude: lng,
                    latitude: lat
                });
                break;
        }
    },
    /**
     * 监听页面显示
     */
    onShow: function () {
        console.log("onShow..");
    },
    // 监听页面隐藏
    onHide() {
        console.log("onHide..");
    }
});